package com.zte.util;

public class DataComparator {

    public static int comparatorSize(String preData,String afterData){
        int flag=0;
        try {
            if (preData !=null && !"".equals(preData) && afterData!=null&&!"".equals(afterData)) {
                int pre = Integer.parseInt(preData);
                int after = Integer.parseInt(afterData);
                if (pre > after) {
                    flag = 1;
                } else if (pre == after) {
                    flag = 0;
                } else {
                    flag = -1;
                }
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return flag;
    }

    public static String[] changeSize(String preData,String afterData){
        String[] ss = new String[2];
        ss[0] = preData;
        ss[1] = afterData;
        if (preData !=null && !"".equals(preData) && afterData!=null&&!"".equals(afterData)) {
            int flag = comparatorSize(preData, afterData);
            if (flag == 1) {
                ss[0] = afterData;
                ss[1] = preData;
            } else if (flag == -1) {
                ss[0] = preData;
                ss[1] = afterData;
            } else {
                ss[0] = ss[1] = preData;
            }
        }
        return ss;
    }
}
